Skip to content

Security: GCUEngine is copyable despite owning a raw executable handle (possible double-free/UAF)#2521

Open
tomaioo wants to merge 1 commit intoPaddlePaddle:developfrom
tomaioo:fix/security/gcuengine-is-copyable-despite-owning-a-r
Open

Security: GCUEngine is copyable despite owning a raw executable handle (possible double-free/UAF)#2521
tomaioo wants to merge 1 commit intoPaddlePaddle:developfrom
tomaioo:fix/security/gcuengine-is-copyable-despite-owning-a-r

Conversation

@tomaioo
Copy link
Copy Markdown

@tomaioo tomaioo commented Apr 23, 2026

Summary

Security: GCUEngine is copyable despite owning a raw executable handle (possible double-free/UAF)

Problem

Severity: High | File: backends/gcu/custom_engine/gcu_engine.h:L22

The GCUEngine class owns tops_exec_ and destroys it in its destructor, but it does not define or delete copy/move constructors and assignment operators. The compiler-generated copy operations will shallow-copy tops_exec_, so multiple GCUEngine instances can end up destroying the same handle. This can cause double-free, use-after-free, or process crashes.

Solution

Apply Rule of Five: delete copy constructor/assignment (GCUEngine(const GCUEngine&) = delete; GCUEngine& operator=(const GCUEngine&) = delete;) and implement safe move semantics, or wrap topsExecutable_t in a unique RAII wrapper with clear ownership.

Changes

  • backends/gcu/custom_engine/gcu_engine.h (modified)

The `GCUEngine` class owns `tops_exec_` and destroys it in its destructor, but it does not define or delete copy/move constructors and assignment operators. The compiler-generated copy operations will shallow-copy `tops_exec_`, so multiple `GCUEngine` instances can end up destroying the same handle. This can cause double-free, use-after-free, or process crashes.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Apr 23, 2026

Thanks for your contribution!

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants